<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>工序(PU)详情</title>
    <!-- 引入 Element UI 的样式 -->
    <link rel="stylesheet" href="../../assets/css/element-ui.css" />
    <link rel="stylesheet" href="../../assets/css/styles.css" />
    <script src="../../assets/js/cdn.js"></script>
    <link rel="stylesheet" href="../../assets/fontawesome-free-6.7.2-web/css/all.min.css" />
  </head>
  <body>
    <div id="app">
      <lx-header slot="header" v-on:toggle="isToggle = !isToggle" :type="2"></lx-header>
      <div class="main-content">
        <div class="content" style="width: 100%">

          <h1 class="module-title">基本信息</h1>
          <div class="center-grid mb-20">
            <el-descriptions :column="4">
              <el-descriptions-item v-for="item in baseInfoHeader" :key="item.fieldApi" :label="item.label">
                <div>{{ formInfo[item.fieldApi] ? formInfo[item.fieldApi]:'-' }}</div>
              </el-descriptions-item>
            </el-descriptions>
          </div>
        </div>
      </div>

    </div>
    <script src="../../assets/js/constant.js"></script>
    <script src="../../assets/js/utils.js"></script>
    <script src="../../assets/js/auth.js"></script>
    <script src="../../assets/js/axios.min.js"></script>
    <!-- 引入 Vue.js -->
    <script src="../../assets/js/vue.js"></script>
    <!-- 引入 Element UI 的 JS 文件 -->
    <script src="../../assets/js/element-ui.js"></script>

    <script type="module">
      import LxHeader from '../../pages/components/LxHeader/index.js'
      Vue.component('lx-header', LxHeader)
      checkAuthentication(2)
      new Vue({
        el: '#app',
        components: {},
        data() {
         return {
            currentUser: JSON.parse(localStorage.getItem('currentUser')) || {},
            userMenuList: JSON.parse(localStorage.getItem('userMenuList')) || [],
            businessCenters: [
                { name: '订单中心', path: '../index.html' },
                { name: '用户中心', path: '#' },
                { name: '产品中心', path: '#' },
                { name: '库存中心', path: '#' },
                { name: '财务中心', path: '#' },
                { name: '数据中心', path: '#' },
                { name: '系统中心', path: '#' },
                { name: '消息中心', path: '#' }
            ],
            baseInfoHeader: [
              { label: '部件工序编号', fieldApi: 'wpuCode' },
              { label: '部件工序名称', fieldApi: 'wpuName'}
            ],
            imageUrl:'',
            dicts: ['base_component_unit','base_tools_type','base_accessories_type','component_attribute'],
            optionsObj: [],
            // 选中数组
            codes: [],
            formInfo: {},
            detailDialog: false, // 详情
            wpuCode: '',
            root_host: root_host,
            request_host: request_host,
            openComponentDia: false,
            openToolDia: false,
            queryParams: {
              pageNo: 1,
              pageSize: 10,
              puCode: '',
              puName: ''
            },
            // 上传相关
            fileList: [],
            headers: {}
          }
        },
        created() {
          this.init()
        },
        methods: {
          exit,
          init() {
            this.wpuCode = getUrlParameter('wpuCode')
            this.getOptions()
            this.getDetails()
          },
          getDetails() {
            // 这里替换为实际的API调用
            axios.get(`${this.request_host}/system/production/` + this.wpuCode)
                .then(response => {
                    this.formInfo = response.data.data
                });
          },
          getOptions() {
                this.dicts.forEach((item) => {
                    axios.get(`${this.request_host}/system/dict/data/type/${item}`).then((response) => {
                        this.$set(this.optionsObj, item, {})
                        if (response.status == 200) {
                            response.data.data.map((item1) => {
                                this.optionsObj[item][item1.dictValue] = item1.dictLabel
                            })
                        }
                    })
                })
          },
          getOptionsStr(opt, value) {
              if (this.optionsObj[opt] && value) {
                  return this.optionsObj[opt][value]
              }
              return ''
          },
          openMenu(url) {
            window.open(url)
          },
        }
      })
    </script>
    <style>
      .el-table th.el-table__cell {
        background-color: #f2f2f2; /* 例如，设置为浅灰色 */
      }
      .mb8 {
            height: 30px;
        }
    </style>
  </body>
</html>
